import React, {useState} from 'react';
import './App.css';
import MainLayout from '@/views/layout/MainLayout'
import {WX_MENU} from '@/constants/menu'
import {connect} from 'react-redux'

import '@/http/socket'
import {
  Switch,
  Route,
  useHistory
} from "react-router-dom";
// import { useHistory } from "react-router-dom";
import ChatList from '@/views/chatList/ChatList'

function App(props: any) {
  const [menus, setMenu] = useState(WX_MENU);
  const {appContext} = props;
  (window as any).$history = useHistory();

  return (
    <MainLayout>
      <Switch>
        {
          menus.map(menu => <Route exact path={menu.to} key={menu.to} title={menu.title} component={menu.component}></Route>)
        }
      </Switch>
    </MainLayout>
  );
}

export default connect(state => ({
  appContext: (state as any).appContext
}))(App);
